<template>
  <!-- 弹框内容 -->
  <div>
    <el-dialog
      :title="title_name"
      :close-on-click-modal="false"
      append-to-body
      :before-close="cenclelist"
      :visible.sync="dialogVisible"
      width="63%"
    >
      <div>
        <el-form
          :inline="true"
          class="demo-form-inline"
          label-width="120px"
          :rules="rules"
          ref="ruleForm"
          :model="ruleForm"
        >
          <el-form-item label="车牌号" prop="license_plate">
            <el-input
              placeholder="车牌号"
              v-model="ruleForm.license_plate"
            ></el-input>
          </el-form-item>
          <el-form-item label="车辆类型" prop="vehicle_type">
            <el-select
              v-model="ruleForm.vehicle_type"
              placeholder="请选择"
              style="width: 172px"
            >
              <el-option
                v-for="item in caroptions"
                :key="item.item_code"
                :label="item.item_name"
                :value="item.item_code"
                :disabled="item.disabled"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="来源" prop="vehicle_source">
            <el-select
              v-model="ruleForm.vehicle_source"
              placeholder="请选择"
              style="width: 172px"
            >
              <el-option
                v-for="item in source_options"
                :key="item.item_code"
                :label="item.item_name"
                :value="item.item_code"
                :disabled="item.disabled"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="车宽">
            <el-input
              v-model="ruleForm.vehicle_width"
              placeholder="车宽cm"
            ></el-input>
          </el-form-item>
          <el-form-item label="车长" prop="vehicle_length">
            <el-input
              v-model="ruleForm.vehicle_length"
              placeholder="车长cm"
            ></el-input>
          </el-form-item>
          <el-form-item label="车高">
            <el-input
              v-model="ruleForm.vehicle_height"
              placeholder="车长cm"
            ></el-input>
          </el-form-item>
          <el-form-item label="车轴数" prop="vehicle_axle_count">
            <el-select
              v-model="ruleForm.vehicle_axle_count"
              placeholder="请选择"
              style="width: 172px"
            >
              <el-option
                v-for="item in axleoptions"
                :key="item.item_code"
                :label="item.item_name"
                :value="item.item_code"
                :disabled="item.disabled"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="载重" prop="vehicle_load">
            <el-input
              v-model="ruleForm.vehicle_load"
              placeholder="载重"
            ></el-input>
          </el-form-item>
          <el-form-item label="净空" prop="space_size">
            <el-input
              v-model="ruleForm.space_size"
              placeholder="净空"
            ></el-input>
          </el-form-item>
          <el-form-item label="车厢长度">
            <el-input
              v-model="ruleForm.wagon_box_length"
              placeholder="车厢长度"
            ></el-input>
          </el-form-item>
          <el-form-item label="车厢宽度">
            <el-input
              v-model="ruleForm.wagon_box_width"
              placeholder="车厢宽度"
            ></el-input>
          </el-form-item>
          <el-form-item label="车厢高度">
            <el-input
              v-model="ruleForm.wagon_box_height"
              placeholder="车厢高度"
            ></el-input>
          </el-form-item>
          <el-form-item label="温控要求" prop="temp_control_type">
            <el-select
              v-model="ruleForm.temp_control_type"
              placeholder="请选择"
              style="width: 172px"
            >
              <el-option
                v-for="item in temoptions"
                :key="item.item_code"
                :label="item.item_name"
                :value="item.item_code"
                :disabled="item.disabled"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="车辆照片">
            <el-upload
              class="upload-demo"
              ref="add-upload"
              action
              multiple
              :auto-upload="false"
              :file-list="ruleForm.vehicle_picture"
              :on-change="
                (file, fileList) => {
                  handleChange(file, fileList, 6);
                }
              "
              :on-remove="
                (file, fileList) => {
                  removeChange(file, fileList, 6);
                }
              "
            >
              <el-button
                slot="trigger"
                size="small"
                icon="el-icon-upload2"
                style="width: 172px"
              >
                上传文件</el-button
              >
            </el-upload>
          </el-form-item>
          <el-form-item label="行车证">
            <el-upload
              class="upload-demo"
              ref="add-upload"
              action
              multiple
              :auto-upload="false"
              :file-list="ruleForm.vehicle_license"
              :on-change="
                (file, fileList) => {
                  handleChange(file, fileList, 7);
                }
              "
              :on-remove="
                (file, fileList) => {
                  removeChange(file, fileList, 7);
                }
              "
            >
              <el-button
                slot="trigger"
                size="small"
                icon="el-icon-upload2"
                style="width: 172px"
              >
                上传文件</el-button
              >
            </el-upload>
          </el-form-item>
          <el-form-item label="运营证">
            <el-upload
              class="upload-demo"
              ref="add-upload"
              action
              multiple
              :auto-upload="false"
              :file-list="ruleForm.operation_license"
              :on-change="
                (file, fileList) => {
                  handleChange(file, fileList, 8);
                }
              "
              :on-remove="
                (file, fileList) => {
                  removeChange(file, fileList, 8);
                }
              "
            >
              <el-button
                slot="trigger"
                size="small"
                icon="el-icon-upload2"
                style="width: 172px"
              >
                上传文件</el-button
              >
            </el-upload>
          </el-form-item>
          <el-form-item
            label="承运商"
            v-if="ruleForm.vehicle_source == '1'"
            prop="carrier_id"
          >
            <el-select
              v-model="ruleForm.carrier_id"
              placeholder="请选择"
              style="width: 172px"
            >
              <el-option
                v-for="item in carrierID"
                :key="item.id"
                :label="item.name"
                :value="item.id"
                :disabled="item.disabled"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="温度计设备">
            <el-select
              v-model="ruleForm.temp_device"
              multiple
              placeholder="请选择"
            >
              <el-option
                v-for="item in threoptionsbox"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="对外共享">
            <el-switch
              v-model="ruleForm.shared"
              active-color="#13ce66"
              inactive-color="#ff4949"
              active-value="1"
              inactive-value="0"
            >
            </el-switch>
          </el-form-item>
          <el-form-item
            label="共享网点"
            v-if="ruleForm.shared == '1'"
            prop="shared_website"
          >
            <el-select
              v-model="ruleForm.shared_website"
              placeholder="请选择"
              multiple
              style="width: 172px"
            >
              <el-option
                v-for="item in originList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="ruleForm.remark" placeholder="备注"></el-input>
          </el-form-item>
          <el-form-item label="是否启用" prop="status">
            <el-switch
              v-model="ruleForm.status"
              active-color="#13ce66"
              inactive-color="#ff4949"
              active-value="0"
              inactive-value="1"
            >
            </el-switch>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button
          :data-tracker="orderstate == '0' ? 'P27-8' : 'P27-10'"
          @click="cenclelist()"
          >取 消</el-button
        >
        <!-- 代表创建的确定 -->
        <el-button
          type="primary"
          data-tracker="P27-7"
          @click="PageAddCar('ruleForm')"
          v-if="orderstate == '0'"
          >确 定
        </el-button>
        <!-- 修改的确定 -->
        <el-button
          type="primary"
          data-tracker="P27-9"
          @click="PageEditCar('ruleForm')"
          v-if="orderstate == '2'"
          >确 定
        </el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
// 通过车辆的来源进行判断是否是内部车辆还是外部车辆
import {
  EditCar,
  DeleteCar,
  DetailsCar,
  AddCar,
  queryCar,
  thermometerbox, //温度计获取
} from "@/api/information";
import {
  uploading,
  PagewebsiteList,
  allcarrierID,
  dictionanryList,
} from "@/page/material/common/common";
export default {
  props: ["dialogVisible"],
  data() {
    return {
      // 组织管理的字段
      originList: [],
      title_name: "车辆",
      // 创建车辆的列表字段
      ruleForm: {
        license_plate: "", //车牌
        vehicle_type: "", //车型
        vehicle_source: "", //来源 0 内部 1 外部
        vehicle_width: "", //车宽
        vehicle_length: "", //车长
        vehicle_height: "", //车高
        vehicle_axle_count: "", //车轴数
        vehicle_load: "", //载重KG
        space_size: "", //净空立方厘米
        wagon_box_length: "", //车厢长cm
        wagon_box_width: "", //车厢宽
        wagon_box_height: "", //车厢高
        temp_control_type: "", //温控要求
        vehicle_picture: [], //车辆照片
        vehicle_license: [], //行驶证
        operation_license: [], //运营证
        carrier_id: "", //承运商id
        status: "0", //状态 0 启用 1 禁用
        remark: "", //备注
        shared: "0", //对外共享
        shared_website: [], //共享网点
        temp_device: [], //温度计设备
      },
      rules: {
        license_plate: [
          { required: true, message: "请填写车牌", trigger: "blur" },
          {
            required: true,
            pattern:
              /^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[DF])|([DABCEFGHJK]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$/,
            message: "请输入正确的车牌号",
            trigger: "blur",
          },
        ],
        vehicle_source: [
          { required: true, message: "请填写来源", trigger: "blur" },
        ],
        vehicle_type: [
          { required: true, message: "请填写车型", trigger: "blur" },
        ], //车型
        // vehicle_length: [
        //   { required: true, message: "请填写车长", trigger: "blur" },
        // ], //车长
        // vehicle_axle_count: [
        //   { required: true, message: "请填写车轴数", trigger: "blur" },
        // ], //车轴数
        // vehicle_load: [
        //   { required: true, message: "请填写载重 ", trigger: "blur" },
        // ], // 载重
        // space_size: [
        //   { required: true, message: "请填写净空 ", trigger: "blur" },
        // ], //净空
        temp_control_type: [
          { required: true, message: "请填写温控要求 ", trigger: "blur" },
        ], //温控要求
        carrier_id: [
          { required: true, message: "请填写承运商 ", trigger: "blur" },
        ], //承运商的id
        shared_website: [
          { required: true, message: "请填写共享网点 ", trigger: "blur" },
        ], //承运商的id
      },
      tableData: [],
      queryparam: {
        license_plate: "", //车牌号
        vehicle_type: "", //车辆类型
        carrier_id: "", //承运商id
        page: 1,
        page_size: 10,
      },
      total: 0, //总条数
      currentPage4: 1,
      deletparam: {
        id: [], //多选删的id
      },
      consignerID: "", //发货人的ID
      orderstate: "0", //选着的是创建还是修改
      // dialogVisible: false, //判断弹框显示隐藏
      source_options: [], //车辆来源
      caroptions: [
        //车辆类型
        {
          value: "金杯",
          label: "金杯",
        },
        {
          value: "4.2米",
          label: "4.2米",
        },
        {
          value: "7.6米",
          label: "7.6米",
        },
        {
          value: "9.6米",
          label: "9.6米",
        },
        {
          value: "17米",
          label: "17米",
        },
        {
          value: "冷藏车",
          label: "冷藏车",
        },
      ],
      temoptions: [], //温控要求
      axleoptions: [], //车轴数
      // 承运商ID
      carrierID: [],
      // 温度计设备
      threoptionsbox: [],
      // maxheight: 400,
    };
  },
  components: {},
  mounted() {
    // 获取组织接口
    this.siteList();
    // 承运商
    this.pageCarrierID();
    // 车辆列表
    this.PagequeryCar();
    // 数据字典
    this.dicList();
    // 温度计box
    this.Pagethermometerbox();
  },
  methods: {
    // 温度计设备
    Pagethermometerbox() {
      var pame = {
        name: "",
      };
      thermometerbox(pame).then((res) => {
        var res = res.data;
        this.threoptionsbox = res;
      });
    },
    // 数据字典
    dicList() {
      var param = [
        "temp_control",
        "vehicle_axle",
        "vehicle_sour",
        "vehicle_type",
      ];
      dictionanryList(param).then((res) => {
        var res = res.data;
        // 温控要求
        this.temoptions = res.list.temp_control;
        // 车轴数
        this.axleoptions = res.list.vehicle_axle;
        // 车辆来源
        this.source_options = res.list.vehicle_sour;
        // 车辆类型
        this.caroptions = res.list.vehicle_type;
      });
    },
    // 获取多选删除的id号
    handleSelectionChange(val) {
      var deleid = [];
      for (var i = 0; i < val.length; i++) {
        deleid.push(val[i].id);
      }
      this.deletparam.id = deleid;
    },
    // 获取id
    handleClick(row, type) {
      if (row == undefined) {
        this.title_name = "创建车辆";
        this.orderstate = "0";
        this.openpop();
        this.clearList();
      } else if (row != "" && type == 1) {
        this.title_name = "查看车辆";
        this.orderstate = "";
        this.openpop();
        this.PageDetailsCar(row.id);
      } else if (row != "" && type == 2) {
        this.title_name = "修改车辆";
        this.orderstate = "2";
        this.consignerID = row.id;
        this.openpop();
        this.PageDetailsCar(row.id);
      }
    },
    // 分页功能
    // 一页有多少条
    handleSizeChange(val) {
      this.queryparam.page_size = val;
      //  数据列表接口
      this.PagequeryCar();
    },
    // 当前第几页
    handleCurrentChange(val) {
      this.queryparam.page = val;
      //  数据列表接口
      this.PagequeryCar();
    },
    // 图片上传功能
    handleChange(file, fileList, type) {
      var filelist = file.raw; //文件
      var filename = file.raw.uid + file.raw.name; //通过 uid和name组成文件的名字
      uploading(filelist, filename, type).then((result) => {
        var resname = result.name;
        var resType = resname.split("/")[0];
        var filehttp = "http://oss.dushisc.com/";
        switch (resType) {
          case "6":
            this.ruleForm.vehicle_picture.push({
              name: filehttp + result.name,
            });

            break;
          case "7":
            // 上传多个列表
            this.ruleForm.vehicle_license.push({
              name: filehttp + result.name,
            });
            break;
          case "8":
            this.ruleForm.operation_license.push({
              name: filehttp + result.name,
            });
            break;
        }
      });
    },
    removeChange(file, fileList, type) {
      switch (type) {
        case 6:
          if (this.ruleForm.vehicle_picture.length > 0) {
            for (var i = 0; i < this.ruleForm.vehicle_picture.length; i++) {
              if (this.ruleForm.vehicle_picture[i].uid == file.uid) {
                this.ruleForm.vehicle_picture.splice(i, 1);
              }
            }
          }

          break;
        case 7:
          if (this.ruleForm.vehicle_license.length > 0) {
            for (var i = 0; i < this.ruleForm.vehicle_license.length; i++) {
              if (this.ruleForm.vehicle_license[i].uid == file.uid) {
                this.ruleForm.vehicle_license.splice(i, 1);
              }
            }
          }
          break;
        case 8:
          if (this.ruleForm.operation_license.length > 0) {
            for (var i = 0; i < this.ruleForm.operation_license.length; i++) {
              if (this.ruleForm.operation_license[i].uid == file.uid) {
                this.ruleForm.operation_license.splice(i, 1);
              }
            }
          }
          break;
      }
    },
    // 组织管理页面
    siteList() {
      PagewebsiteList("0").then((res) => {
        this.originList = res.data;
      });
    },
    // 承运商管理id
    pageCarrierID() {
      allcarrierID().then((res) => {
        var res = res.data;
        this.carrierID = res;
      });
    },
    // 编辑车辆
    PageEditCar(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var picturename =
            this.ruleForm.vehicle_picture.length == 0
              ? ""
              : this.ruleForm.vehicle_picture[0].name;

          var licensename =
            this.ruleForm.vehicle_license.length == 0
              ? ""
              : this.ruleForm.vehicle_license[0].name;

          var operationname =
            this.ruleForm.operation_license.length == 0
              ? ""
              : this.ruleForm.operation_license[0].name;
          var param = {
            id: this.consignerID,
            license_plate: this.ruleForm.license_plate,
            vehicle_type: this.ruleForm.vehicle_type,
            vehicle_source: this.ruleForm.vehicle_source,
            vehicle_width: this.ruleForm.vehicle_width,
            vehicle_length: this.ruleForm.vehicle_length,
            vehicle_height: this.ruleForm.vehicle_height,
            vehicle_axle_count: this.ruleForm.vehicle_axle_count,
            vehicle_load: this.ruleForm.vehicle_load,
            space_size: this.ruleForm.space_size,
            wagon_box_length: this.ruleForm.wagon_box_length,
            wagon_box_width: this.ruleForm.wagon_box_width,
            wagon_box_height: this.ruleForm.wagon_box_height,
            temp_control_type: String(this.ruleForm.temp_control_type),
            vehicle_picture: String(picturename),
            vehicle_license: String(licensename),
            operation_license: String(operationname),
            carrier_id: String(this.ruleForm.carrier_id),
            status: this.ruleForm.status,
            remark: this.ruleForm.remark,
            shared: String(this.ruleForm.shared),
            shared_website: this.ruleForm.shared_website,
            temp_device: this.ruleForm.temp_device, //温度计设备
          };
          EditCar(param).then((res) => {
            if (res.code == 10000) {
              this.closepop();
              this.PagequeryCar();
              this.$message({
                message: "修改数据成功",
                type: "success",
              });
            } else {
              this.$message({
                message: res.message,
                type: "warning",
              });
            }
          });
        } else {
          // console.log("error submit!!");
          return false;
        }
      });
    },
    // 删除车辆
    PageDeleteCar() {
      var str = JSON.stringify(this.deletparam);
      DeleteCar(str).then((res) => {
        if (res.code == 10000) {
          this.PagequeryCar();
          this.$message({
            message: "删除数据成功",
            type: "success",
          });
        }
      });
    },
    // 车辆详情
    PageDetailsCar(id) {
      var params = {
        id: id,
      };
      DetailsCar(params).then((res) => {
        var res = res.data;
        var picturelist = [];
        if (res.vehicle_picture == "") {
          picturelist = [];
        } else {
          picturelist.push({ name: [res.vehicle_picture] });
        }
        var licenselist = [];
        if (res.vehicle_license == "") {
          licenselist = [];
        } else {
          licenselist.push({ name: [res.vehicle_license] });
        }
        var operation = [];
        if (res.operation_license == "") {
          operation = [];
        } else {
          operation.push({ name: [res.operation_license] });
        }
        var tepmList = [];
        if (res.temp_device_info != null) {
          res.temp_device_info.forEach((res) => {
            tepmList.push(res.id);
          });
        }
        var sharedList = [];
        if (res.shared_website_info != null) {
          res.shared_website_info.forEach((res) => {
            sharedList.push(res.id);
          });
        } else {
          sharedList = [];
        }

        this.ruleForm.license_plate = res.license_plate; //车牌
        this.ruleForm.vehicle_type = res.vehicle_type; //车型
        this.ruleForm.vehicle_source = res.vehicle_source; //来源 0 内部 1 外部
        this.ruleForm.vehicle_width = res.vehicle_width; //车宽
        this.ruleForm.vehicle_length = res.vehicle_length; //车长
        this.ruleForm.vehicle_height = res.vehicle_height; //车高
        this.ruleForm.vehicle_axle_count = res.vehicle_axle_count; //车轴数
        this.ruleForm.vehicle_load = res.vehicle_load; //载重KG
        this.ruleForm.space_size = res.space_size; //净空立方厘米
        this.ruleForm.wagon_box_length = res.wagon_box_length; //车厢长cm
        this.ruleForm.wagon_box_width = res.wagon_box_width; //车厢宽
        this.ruleForm.wagon_box_height = res.wagon_box_height; //车厢高
        this.ruleForm.temp_control_type = res.temp_control_type; //温控要求
        this.ruleForm.vehicle_picture = picturelist;
        this.ruleForm.vehicle_license = licenselist;
        this.ruleForm.operation_license = operation;
        this.ruleForm.carrier_id = Number(res.carrier_id); //承运商id
        this.ruleForm.status = res.status; //状态 0 启用 1 禁用
        this.ruleForm.remark = res.remark; //备注
        this.ruleForm.shared = String(res.shared); //对外共享
        this.ruleForm.temp_device = tepmList;
        this.ruleForm.shared_website = sharedList;
      });
    },
    // 创建车辆信息
    PageAddCar(formName) {
      this.$refs[formName].validate((valid) => {
        // console.log(typeof this.ruleForm.shared_website);
        if (valid) {
          var picturename =
            this.ruleForm.vehicle_picture.length == 0
              ? ""
              : this.ruleForm.vehicle_picture[0].name;

          var licensename =
            this.ruleForm.vehicle_license.length == 0
              ? ""
              : this.ruleForm.vehicle_license[0].name;

          var operationname =
            this.ruleForm.operation_license.length == 0
              ? ""
              : this.ruleForm.operation_license[0].name;
          var param = {
            license_plate: this.ruleForm.license_plate, //车牌
            vehicle_type: this.ruleForm.vehicle_type, //车型
            vehicle_source: this.ruleForm.vehicle_source, //来源 0 内部 1 外部
            vehicle_width: this.ruleForm.vehicle_width, //车宽
            vehicle_length: this.ruleForm.vehicle_length, //车长
            vehicle_height: this.ruleForm.vehicle_height, //车高
            vehicle_axle_count: this.ruleForm.vehicle_axle_count, //车轴数
            vehicle_load: this.ruleForm.vehicle_load, //载重KG
            space_size: this.ruleForm.space_size, //净空立方厘米
            wagon_box_length: this.ruleForm.wagon_box_length, //车厢长cm
            wagon_box_width: this.ruleForm.wagon_box_width, //车厢宽
            wagon_box_height: this.ruleForm.wagon_box_height, //车厢高
            temp_control_type: String(this.ruleForm.temp_control_type), //温控要求
            vehicle_picture: String(picturename), //车辆照片
            vehicle_license: String(licensename), //行驶证
            operation_license: String(operationname), //运营证
            carrier_id: String(this.ruleForm.carrier_id), //承运商id
            status: this.ruleForm.status, //状态 0 启用 1 禁用
            remark: this.ruleForm.remark, //备注
            shared: this.ruleForm.shared, //对外共享
            shared_website: this.ruleForm.shared_website, //共享网点
            temp_device: this.ruleForm.temp_device, //温度计设备
          };
          AddCar(param).then((res) => {
            if (res.code == 10000) {
              this.closepop();
              // this.PagequeryCar();
              this.$message({
                message: "创建数据成功",
                type: "success",
              });
              this.$emit("ok");
            } else {
              this.$message({
                message: res.message,
                type: "warning",
              });
            }
          });
        } else {
          // console.log("error submit!!");
          return false;
        }
      });
    },
    // 查询车辆
    PagequeryCar() {
      var querlist = {
        license_plate: this.queryparam.license_plate, //车牌号
        vehicle_type: this.queryparam.vehicle_type, //车辆类型
        carrier_id: String(this.queryparam.carrier_id), //承运商id
        page: this.queryparam.page,
        page_size: this.queryparam.page_size,
      };
      queryCar(querlist).then((res) => {
        var res = res.data;
        this.total = res.pagination.total;
        if (res.list == null) {
          var list = [];
          this.DataState(list);
        } else {
          this.DataState(res.list);
        }
      });
    },
    // 处理数据函数
    DataState(res) {
      res.forEach((item) => {
        let branch_name_list = [];
        if (item.shared_website_info != null) {
          for (var j = 0; j < item.shared_website_info.length; j++) {
            branch_name_list.push(item.shared_website_info[j].name + "/");
          }
        }
        item.shared_website_info = branch_name_list;
        var tempName = [];
        if (item.temp_device_info != null) {
          item.temp_device_info.forEach((res) => {
            tempName.push(res.name + "/");
          });
        }
        item.temp_device_info = tempName;
        item.status = item.status === "0" ? "启用" : "禁用";
        item.shared = item.shared == "0" ? "不对外共享" : "对外共享";
        item.vehicle_source =
          item.vehicle_source == "0" ? "内部车辆" : "外部车辆";
        switch (item.vehicle_type) {
          case "0":
            item.vehicle_type = "金杯";
            break;
          case "1":
            item.vehicle_type = "4.2米";
            break;
          case "2":
            item.vehicle_type = "7.6米";
            break;
          case "3":
            item.vehicle_type = "9.6米";
            break;
          case "4":
            item.vehicle_type = "17米";
            break;
          case "5":
            item.vehicle_type = "冷藏车";
            break;
        }
        switch (item.vehicle_axle_count) {
          case "0":
            item.vehicle_axle_count = "2轴";
            break;
          case "1":
            item.vehicle_axle_count = "3轴";
            break;
          case "2":
            item.vehicle_axle_count = "4轴";
            break;
        }
        switch (item.temp_control_type) {
          case "0":
            item.temp_control_type = "冷冻(-15 ~ -30)";
            break;
          case "1":
            item.temp_control_type = "阴凉(15 ~ 25)";
            break;
          case "2":
            item.temp_control_type = "冷藏(2 ~ 8)";
            break;
          case "3":
            item.temp_control_type = "常温(0 ~ 30)";
            break;
          case "4":
            item.temp_control_type = "低温( -20 ~ -80 )";
            break;
        }
      });
      this.tableData = res;
    },
    // 取消数据
    cenclelist() {
      this.closepop();
      this.clearList();
    },
    // 关闭弹框的函数
    closepop() {
      // this.dialogVisible = false;
      this.$emit("close");
    },
    openpop() {
      this.dialogVisible = true;
    },
    // 清空数据
    clearList() {
      this.ruleForm = {
        license_plate: "", //车牌
        vehicle_type: "", //车型
        vehicle_source: "", //来源 0 内部 1 外部
        vehicle_width: "", //车宽
        vehicle_length: "", //车长
        vehicle_height: "", //车高
        vehicle_axle_count: "", //车轴数
        vehicle_load: "", //载重KG
        space_size: "", //净空立方厘米
        wagon_box_length: "", //车厢长cm
        wagon_box_width: "", //车厢宽
        wagon_box_height: "", //车厢高
        temp_control_type: "", //温控要求
        vehicle_picture: [], //车辆照片
        vehicle_license: [], //行驶证
        operation_license: [], //运营证
        carrier_id: "", //承运商id
        status: "0", //状态 0 启用 1 禁用
        remark: "", //备注
        shared: "0", //对外共享
        shared_website: [], //共享网点
        temp_device: [], //温度计设备
      };
    },
    // 重置数据
    restequery() {
      this.queryparam.license_plate = "";
      this.queryparam.vehicle_type = "";
      this.queryparam.carrier_id = "";
      this.PagequeryCar();
    },
  },
};
</script>

<style lang="less" scoped>
.shareContainer {
  padding: 10px;
  // margin-top: 5px;
  margin-left: 5px;
  background-color: #fff;

  .shareheader {
    background: white;

    .shareheader_top {
      display: flex;
      flex-wrap: wrap;
    }
  }

  // 内容
  .sharecontent {
    background: white;

    // 头部内容
    .sharecontent_header {
      .sharecontent_header_right {
        display: inline-block;
      }

      .sharecontent_header_left {
        float: right;
        padding: 0px 8px 0px 0px;
      }
    }

    // 表单内容
    .sharecontent_content {
    }
  }
}
</style>
